package com.xiaohudie.thread;

/**
 * @Author xiao hu die
 * @Date 2022/2/21 10:35
 * @Version 1.0
 */
public class Test04 {
    public static void main(String[] args) {
        Thread3 thread3 = new Thread3();
        thread3.setName("小蝴蝶");
        thread3.start();
        Thread3 thread31 = new Thread3();
        thread31.setName("刘碟");
        thread31.start();
        Thread3 thread311 = new Thread3();
        thread311.start();
        for (int i = 0; i <10 ; i++) {
            System.out.println("线程名字为:" +Thread.currentThread().getName());
        }
    }
static class Thread3 extends Thread{
        @Override
         public void run(){
          //  Thread thread = new Thread();
            for (int i = 0; i <10 ; i++) {
                /**获得当前线程对象，不是开辟一个新的线程*/
                Thread thread = Thread.currentThread();
                System.out.println("线程名字为:"+thread.getName());
            }
        }
}
}
